package alwv.database;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSetMetaData;



public class DerbyConnection {
    private static String dbURL = "jdbc:derby:C:/ALWV/db/current/LWV;create=false;";
    private static Connection conn = null;
    private static Statement stmt = null;

    public static void main(String[] args) {
        createConnection();
        shutdown();
    }
    
    public static void createConnection() {
        try  {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
            //Get a connection
            conn = DriverManager.getConnection(dbURL); 
        }
        catch (Exception except) {
            except.printStackTrace();
        }
    }
    
    private static void shutdown() {
        try {
            if (stmt != null) {
                stmt.close();
            }
            if (conn != null) {
                //DriverManager.getConnection(dbURL + ";shutdown=true");
                
            }           
        }
        catch (SQLException e) {
            e.printStackTrace();
        }

    }
    
    public Connection getConnection() {
        return conn;
    }
}